﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Objects;
using System.Linq;
using System.Web;
using System.Web.Util;
using System.Data.Common;
using MvcBase;


namespace NapCardOnline.Models
{
    [BaseValidationAttribute.CompareTo(BaseValidationAttribute.CompareToOperation.GreaterThan, "FromUserLevel", "ToUserLevel")]
    public partial class TransferFundType
    {
        static Models.NapCardOnlineEntities db = new NapCardOnlineEntities();

        [Required]
        [Display(Name = "Cấp độ TK chuyển")]
        public int FromUserLevel { get; set; }

        [Display(Name = "Cấp độ TK nhận")]
        public int ToUserLevel { get; set; }

        /// <summary>
        /// Gets the transfer fund type by user.
        /// </summary>
        /// <param name="fromUserLevel">From user level.</param>
        /// <param name="toUserLevel">To user level.</param>
        /// <returns>
        /// The transferfund type id.
        /// </returns>
        public static int GetTransferFundTypeByUserLevel(int? fromUserLevel,int? toUserLevel)
        {
            int transferFundTypeId = 0;
            if(fromUserLevel==(int)Enum.UserLevel.Level1 && toUserLevel==(int)Enum.UserLevel.Level1)
            {
                transferFundTypeId = (int)Enum.TransferFundType.AgentToAgent;
            }

            if (fromUserLevel == (int)Enum.UserLevel.Level1 && toUserLevel == (int)Enum.UserLevel.Level2)
            {
                transferFundTypeId = (int) Enum.TransferFundType.AgentToUser;
            }
            //TODO: if have more rule will add continue
            return transferFundTypeId;
        }
    }

}